#include "comm.hpp"
#include "com.hpp"
int main()
{
    Init init;
    // 创建
    int shmid = Creat_shamem();
    // 连接
    char *shmaddr = (char *)shmat(shmid, nullptr, 0);

    int fd = open(FIFO_FILE, O_RDONLY);
    if (fd < 0)
    {
        log(Info, "errno string: %s , errno code: %d", strerror(errno), errno);
        exit(FIFO_OPEN_ERR);
    }

    while (true)
    {
        char c;
        ssize_t n = read(fd, &c, 1);
        if (n <= 0)
            break;
        cout << "client say$ ";
        cout << shmaddr << endl;
    }
    // 解除连接
    shmdt(shmaddr);
    // 关闭共享内存
    shmctl(shmid, IPC_RMID, nullptr);

    return 0;
     //return 0;
}